

package com.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import com.model.Guess;
import java.sql.SQLException;
import java.util.List;
import java.util.ArrayList;
import com.service.UserService;


public class EntertainmentController extends HttpServlet {
   
 
 

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

         List<Guess> entertainmentList = new ArrayList<Guess>();

            try {

            UserService userService = new UserService();

            userService.setConnection();

             List<Guess> list = userService.getAllGuess();

             for(int i = 0; i < list.size(); i++){

                 Guess guess = list.get(i);

                 if(guess.getGuessCategory().equalsIgnoreCase("entertainment") )  {

                               entertainmentList.add(guess);

                       }


             }

             userService.closeConnection();

             request.setAttribute("entertainmentList", entertainmentList);
             RequestDispatcher  requestDispatcher = request.getRequestDispatcher("/entertainment.jsp");
             requestDispatcher.forward(request, response);




        } catch (ClassNotFoundException ex) {
          ex.printStackTrace();
        } catch (SQLException ex) {
           ex.printStackTrace();
        }






    } 

  
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
       
    }



}
